package cn.tedu.cwfw.order.service.Impl;

import cn.tedu.cwfw.base.response.JsonResult;

import cn.tedu.cwfw.order.mapper.OrderMapper;
import cn.tedu.cwfw.order.pojo.dto.OrderDTO;
import cn.tedu.cwfw.order.pojo.vo.OrderVO;
import cn.tedu.cwfw.order.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
@Transactional
@Service
@Slf4j
public class OrderServiceImpl implements OrderService{

    @Autowired
    private OrderMapper orderMapper;

    //增加订单
    @Override
    public void addOrder(OrderVO orderVO) {
        log.debug("增加订单：{}", orderVO);
        orderMapper.addOrder(orderVO);
        log.debug("添加店铺信息成功");

    }

    //查询订单列表
    @RequestMapping("list")
    public List<OrderVO> findOrder(OrderDTO orderDTO){
        log.debug("查询订单列表：{}", orderDTO);
        List<OrderVO> orderVOList = orderMapper.findOrder(orderDTO);
        return orderVOList;

    }

    @Override
    public OrderVO findOrderById(Long id){
        log.debug("根据id查看订单详情：{}",id);
        OrderVO orderVO = orderMapper.findOrderById(id);
        return orderVO;
    }

    @Override
    public void deleteOrder(Long id){
        log.debug("根据id删除订单：{}",id);
        orderMapper.deleteOrder(id);
        log.debug("根据id删除订单成功");

    }




}
